package offer.diff;

/**
 * @author DengYuan2
 * @create 2021-03-19 19:48
 */
public class n_49 {
    public static void main(String[] args) {
        n_49 n = new n_49();

    }

    public int GetUglyNumber_Solution(int index) {
        if (index<=6){
            return index;
        }
        int x2=0;
        int x3=0;
        int x5=0;
        int[] arr=new int[index];
        arr[0]=1;
        for (int i = 1; i < index; i++) {
            int y2=2*arr[x2];
            int y3=3*arr[x3];
            int y5=5*arr[x5];
            arr[i]=Math.min(y2,Math.min(y3,y5));
            if (arr[i]==y2){
                x2++;
            }
            if (arr[i]==y3){
                x3++;
            }
            if (arr[i]==y5){
                x5++;
            }
        }
        return arr[index-1];
    }
}
